<template>
  <div class="main">
    <van-card
      :desc="user.dept.deptName"
      :title="user.nickName"
      thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
    />
    <van-collapse v-model="activeName" accordion>
      <van-collapse-item
        :title="courseClass.course.courseName + courseClass.courseclassNo"
        :name="courseClass.courseclassId"
        v-for="(courseClass, courseindex) in courseclassList"
        :key="courseindex"
      >
        <SPAN v-for="(metaClass, classindex) in metaClassList" :key="classindex">
          {{ metaClass.metaclassName }}
        </SPAN>
      </van-collapse-item>
    </van-collapse>

  </div>
</template>

<script>
import { getActivityData } from "@/api/dingding/list.js";
import { getUserProfile } from "@/api/system/user";
import { getCourseListForOneTeacher } from "@/api/pingjiao/teacher.js";
import { Toast } from "vant";
export default {
  name: "User",
  data() {
    return {
      user: {
        dept: {
          deptName: "所属部门",
        },
        nickName: "用户姓名",
      },
      activeName: [1],
      courseclassList: [
        {
          courseclassId: 6694,
          courseclassNo: "2021-202202380007-036",
          course: {
            courseName: "形势与政策（二）",
          },
        },
        {
          courseclassId: 6695,
          courseclassNo: "2021-202202380007-035",
          course: {
            courseName: "形势与政策（一）",
          },
        },
      ],
      metaClassList: [
        {
          metaclassName: "21电商6班",
        },
        {
          metaclassName: "21电商7班",
        },
      ],
      roleGroup: {}, //存储角色显示不同的界面
      postGroup: {},
      teacherLoading: false,
      teacherFinished: false,
      studentLoading: false,
      studentFinished: false,
      activityList: [
        {
          id: 1,
          name: "评价问卷1",
        },
        {
          id: 2,
          name: "评价问卷1",
        },
        {
          id: 3,
          name: "评价问卷1",
        },
        {
          id: 4,
          name: "评价问卷1",
        },
      ],
      studentVoList: [
        {
          id: 1,
          name: "评价问卷1",
        },
        {
          id: 2,
          name: "评价问卷1",
        },
        {
          id: 3,
          name: "评价问卷3",
        },
        {
          id: 4,
          name: "评价问卷4",
        },
      ],
    };
  },
  created() {
    this.$emit("show", 2); //传递给父组件改变tab的激活active样式
    this.getUser();
    this.getCourseList();
  },
  watch: {},
  methods: {
    //角色名 user.roles[0].roleName
    //用户名 user.nickName
    //所属院系 user.dept.deptName
    getUser() {
      getUserProfile().then((response) => {
        console.log("getUserProfile", response);
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    },

    gotoTeacherList: function (evalutionActivityId) {
      this.$router.push({
        path: "/dingding/teacherList",
        query: {
          evalutionActivityId: evalutionActivityId,
        },
      });
    },
    onTeacherLoad() {
      this.teacherLoading = true; // 加载状态开始
      getListById(1)
        .then((res) => {
          this.teacherVoList = res.data.teacherVoList;
          this.loading = false; // 加载状态结束
          this.finished = true; //提示列表加载完成
        })
        .catch((error) => {
          this.error = true; //提示列表加载出错点击重新加载
        });
    },
    getCourseList(){//获取所属课程列表
      console.log("准备获取所属课程列表");
      getCourseListForOneTeacher()
      .then((res) => {
        console.log("所属课程列表",res);
        alert(res.data.courseclassList[0].course.courseName)
          this.courseclassList = res.data.courseclassList;
        })
        .catch((error) => {
          console.log("获取课程信息出错",error);
        });
    }
  },
};
</script>

<style  rel="stylesheet/scss" lang="scss">
</style>